package com.hrm.controller.popup;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractFormController;

import com.hrm.model.dto.insa.EmployeeDTO;
import com.hrm.model.service.CamService;
import com.hrm.model.service.EmployeeService;

public class PopEmployeeListController extends AbstractFormController {
	private EmployeeService employeeService;
	
	public void setEmployeeService(EmployeeService employeeService) {
		this.employeeService = employeeService;
	}

	@Override
	protected ModelAndView processFormSubmission(HttpServletRequest request,
			HttpServletResponse arg1, Object arg2, BindException arg3)
			throws Exception {
		
		ModelAndView mv = new ModelAndView();

		String command = request.getParameter("command");
		String formId = request.getParameter("formId");
		mv.addObject("command", command);
		mv.addObject("formId", formId);
		
		List list = employeeService.getAllEmployee((EmployeeDTO)arg2);
		mv.addObject("list", list);
		
		mv.setViewName("popEmployeeList");
		
		return mv;
	}

	@Override
	protected ModelAndView showForm(HttpServletRequest request,
			HttpServletResponse arg1, BindException arg2) throws Exception {
		
		ModelAndView mv = new ModelAndView();
		
		String command = request.getParameter("command");
		String formId = request.getParameter("formId");	
		mv.addObject("command", command);
		mv.addObject("formId", formId);
		
		mv.setViewName("popEmployeeList");
		return mv;
	}

}
